
SocialMailchimp = function( vars )	{

	Object.extend( obj = $$( '.SocialMailchimp form' ).pop(), SocialMailchimp.proto );
	
	obj.vars		= vars;
	obj.enabled		= true;
	obj.submit		= obj.select( 'input[type="button"]' ).pop();
		
	return obj;
}



SocialMailchimp.proto =	{

	subscribe			: function() {
	
		this.submit.observe( 'click', function( e ) {
			
			e.preventDefault();
			var answer	= this.serialize( true );
			xhttp.send( '/xhttp.mod', {
				mod: "social.mailchimp",
				action: "subscribe",
				vars: Object.extend( answer, { vars: obj.vars })
			}, this.pull_response.bind( this ) );
			
		}.bind( this ));
		
		
	},
	
	pull_response		: function( response ) {
	
		this.disable();
		this.insert( new Element( "span", { 'class': 'update' }).update( response.responseText ));
	}
	
	
	
	
}
